package top.chmin.project.cloud.common.entity;

/**
 * chmin
 * 2023/12/19 13:33
 * cloud-builder
 */
public abstract class StringEPCField<T extends PreCondition> {

    T t;
    String columnName;
    String value;

    public StringEPCField(T t, String columnName, String value) {
        this.t = t;
        this.columnName = columnName;
        this.value = value;
    }

    public T eq() {
        t.addSql(columnName + " = ?", value);
        return t;
    }

    public T ne() {
        t.addSql(columnName + " <> ?", value);
        return t;
    }

    public T like() {
        t.addSql(columnName + " like CONCAT('%%', ?, '%%')", value);
        return t;
    }

    public T leftLike() {
        t.addSql(columnName + " like CONCAT(?, '%%')", value);
        return t;
    }

    public T rightLike() {
        t.addSql(columnName + " like CONCAT('%%', ?)", value);
        return t;
    }

    public T group() {
        t.addGroup(columnName);
        return t;
    }

    public T asc() {
        t.addOrder(columnName);
        return t;
    }

    public T desc() {
        t.addOrder(columnName + " DESC");
        return t;
    }
}
